<extend name="Home@Include:Layout"/>
<block name="title">打赏支付</block>
<block name="style">

</block>

<block name="main">
	<div class="weui_tab">
		<div class="weui_navbar">
			<div class="toolbar">
		        <div class="toolbar-inner">
		            <a href="javascript:history.go(-1);" class="picker-button close-popup">返回</a>
		             <h1 class="title" id="banji_title">打赏信息</h1> 
		        </div>
		    </div>
		</div>
		<div class="weui_tab_bd container" id="container" style="padding-top:44px;">
			<div class="weui_panel weui_panel_access">
			  <div class="weui_panel_bd">
			    <a href="javascript:void(0);" class="weui_media_box weui_media_appmsg">
			      <div class="weui_media_hd">
			        <php>
			        	$teacherinfo['teacher']['avater']?$headimg=$teacherinfo['teacher']['avater']:$headimg=$teacherinfo['teacher']['headimgurl'];</php>
			        <img class="weui_media_appmsg_thumb" src="{$headimg|default='/Public/Static/Img/txlogo.jpg'}" alt="">
			      </div>
			      <div class="weui_media_bd">
			        <h4 class="weui_media_title">{$teacherinfo.teacher.realname}<notempty name="teacherinfo['teacher']['english']">({$teacherinfo.teacher.english})</notempty></h4>
			        <p class="weui_media_desc">{$teacherinfo.kecheng}</p>
			      </div>
			    </a>
			  </div>
			</div>
			<div class="weui_cells weui_cells_form" style="margin-top:10px;">
				<div class="weui_cell">
			     <div class="weui_cell_hd"><label class="weui_label">金额</label></div>
			     <div class="weui_cell_bd weui_cell_primary">
			       {$info.total}
			     </div>
			    </div>
			</div>
			<eq name="info['status']" value="2">
			<div style="padding:15px;">
				<button class="weui_btn weui_btn_primary weixinPayBtn">支付</button>
			</div>
			</eq>
		</div>
	</div>
</block>

<block name="script">
<script>
$(".weixinPayBtn").on('click',function(){
	callpay();
})
function jsApiCall(){
	WeixinJSBridge.invoke(
		'getBrandWCPayRequest',
		<?php echo $jsApiParameters; ?>,
		function(res){
			//如果支付成功
			if (res.err_msg == 'get_brand_wcpay_request:ok') {
				$.alert('支付成功',"", function(){
					location.href="/Home/Fuwu/detail/uid/{$teacherinfo.id}/did/{$info.did}.html";
		        });
			}else if (res.err_msg == 'get_brand_wcpay_request:cancel') {
				$.toast('请尽快完成支付哦！','text');
			}else if (res.err_msg == 'get_brand_wcpay_request:fail') {
				$.toast('支付失败','text');
			}else {
				$.toast('意外错误','text');
			}
		}
	);
}
function callpay(){
	if (typeof WeixinJSBridge == "undefined"){
	    if( document.addEventListener ){
	        document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
	    }else if (document.attachEvent){
	        document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
	        document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
	    }
	}else{
	    jsApiCall();
	}
}
</script>
</block>